/**
 * Copyright (c) 2013 onionframework.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package org.onionframework.code.model;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.validator.constraints.Length;
import org.onionframework.persistence.model.AbstractModel;
import org.onionframework.persistence.model.annotation.DomainModel;

/**
 * 业务代码类型
 * @author allan
 *
 */
@Entity
@Table(name="T_CODE_CODETYPE")
@DomainModel(name="业务代码类型")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class CodeType extends AbstractModel{

	private static final long serialVersionUID = -362202793168762715L;
	private String name;
	private String description;
	private String dataRange;
	
	/**
	 * @return the name
	 */
	@Pattern(regexp="^[a-zA-z0-9_\\.]+$",message="代码类型名称应该只包含数字、字母、下划线和点")
	@Length(min = 1, max = 100, message="代码类型名称长度范围{min}-{max}")
	public String getName() {
		return name;
	}
	
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * @return the description
	 */
	@Length(min = 1, max = 255, message="代码类型说明长度范围{min}-{max}")
	public String getDescription() {
		return description;
	}
	
	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	public String toString(){
		return this.name;
	}

	/**
	 * @return the dataRange
	 */
	public String getDataRange() {
		return dataRange;
	}

	/**
	 * @param dataRange the dataRange to set
	 */
	public void setDataRange(String dataRange) {
		this.dataRange = dataRange;
	}
}
